/*
 *  $Id: Color.cs 1205 2010-11-23 15:50:19Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008-2010 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

using AgateLib.Geometry;

using Nereal.Serialization;
using Nereal.Serialization.TypeInfos;

namespace Ragima.Serialization {
    [TypeInfo(typeof(Color))]
    public class ColorTypeInfo : ValueTypeInfo<Color> {
        public override bool Equals(Color a, Color b) {
            return a == b;
        }

        public override Color ConvertFromString(string value) {
            return Color.FromArgb(value);
        }

        public override string ConvertToString(Color value) {
            var argb = value.ToArgb();
            return value.A == byte.MaxValue ? (argb & 0xffffff).ToString("X6") : argb.ToString("X8");
        }
    }
}
